function OtherAlbumDesign() {
};

OtherAlbumDesign.instance = function(callbackFunc) {
  var popupBox = new PopupBox(), _self = this;
  var popupBox2 = new PopupBox2();
  var model = Model.instance('{{$smarty.const.MODEL_NAME_ALBUM_DESIGN|escape:javascript}}', '{{$smarty.const.MODEL_TITLE_ALBUM_DESIGN|escape:javascript}}', '{{$smarty.const.MODEL_TYPE_OTHER|escape:javascript}}');
  
  //Create model here...
  var state1 = State.instance(model, 0, 'not activate');
  var state2 = State.instance(model, 1, 'receive CUS photo requirement');
  var state3 = State.instance(model, 2, 'arrange designer');
  var state4 = State.instance(model, 3, 'translate and upload CUS requirement');
  var state5 = State.instance(model, 4, 'download CUS requirement and select photos');
  var state6 = State.instance(model, 5, 'completed and upload design');
  var state7 = State.instance(model, 6, 'check and sent design Draft to CUS');
  var state8 = State.instance(model, 7, 'receive CUS feedback');
  var state9 = State.instance(model, 8, 'check CUS feedback');
  var state10 = State.instance(model, 9, 'translate and upload CUS requirement');
  var state11 = State.instance(model, 10, 'download CUS requirement');
  var state12 = State.instance(model, 11, 'upload design (HD)');
  var state13 = State.instance(model, 12, 'download design (HD)');
  var state14 = State.instance(model, 13, 'design is completed');
  
  var transition1 = Transition.instance('received', state2, state3, '{{$smarty.const.USER_TYPE_MANAGER_ASSISTANT|escape:javascript}}', DlmanageUtils.normal, 5);
  var transition2 = Transition.instance('rmd CUS', state2, state2, '{{$smarty.const.USER_TYPE_MANAGER_ASSISTANT|escape:javascript}}', DlmanageUtils.mixed, 30);
  var transition3 = Transition.instance('arrange', state3, state4, '{{$smarty.const.USER_TYPE_CUSTOMER_SERVICE|escape:javascript}}', DlmanageUtils.normal, 0);
  var transition4 = Transition.instance('uploaded', state4, state5, '{{$smarty.const.USER_TYPE_CUSTOMER_SERVICE|escape:javascript}}', DlmanageUtils.normal, 1);
  var transition5 = Transition.instance('downloaded', state5, state6, '{{$smarty.const.USER_TYPE_DESIGNER|escape:javascript}}', DlmanageUtils.normal, 9);
  var transition6 = Transition.instance('uploaded', state6, state7, '{{$smarty.const.USER_TYPE_DESIGNER|escape:javascript}}', DlmanageUtils.normal, 3);
  var transition7 = Transition.instance('sent', state7, state8, '{{$smarty.const.USER_TYPE_CUSTOMER_SERVICE|escape:javascript}}', DlmanageUtils.normal, 14);
  var transition8 = Transition.instance('received', state8, state9, '{{$smarty.const.USER_TYPE_MANAGER_ASSISTANT|escape:javascript}}', DlmanageUtils.normal, 3);
  var transition9 = Transition.instance('rmd CUS', state8, state8, '{{$smarty.const.USER_TYPE_MANAGER_ASSISTANT|escape:javascript}}', DlmanageUtils.mixed, 7);
  var transition10 = Transition.instance('confirmed', state9, state12, '{{$smarty.const.USER_TYPE_CUSTOMER_SERVICE|escape:javascript}}', DlmanageUtils.normal, 1);
  var transition11 = Transition.instance('modify', state9, state10, '{{$smarty.const.USER_TYPE_CUSTOMER_SERVICE|escape:javascript}}', DlmanageUtils.normal, 0);
  var transition12 = Transition.instance('uploaded', state10, state11, '{{$smarty.const.USER_TYPE_CUSTOMER_SERVICE|escape:javascript}}', DlmanageUtils.normal, 1);
  var transition13 = Transition.instance('downloaded', state11, state6, '{{$smarty.const.USER_TYPE_DESIGNER|escape:javascript}}', DlmanageUtils.normal, 9);
  var transition14 = Transition.instance('uploaded', state12, state13, '{{$smarty.const.USER_TYPE_DESIGNER|escape:javascript}}', DlmanageUtils.normal,2);
  var transition15 = Transition.instance('downloaded', state13, state14, '{{$smarty.const.USER_TYPE_FACTORY|escape:javascript}}', DlmanageUtils.none, 2);
  
  var transition16 = Transition.instance('received', state8, state9, '{{$smarty.const.USER_TYPE_CUSTOMER_SERVICE|escape:javascript}}', DlmanageUtils.normal, 3);
  var transition17 = Transition.instance('rmd CUS', state8, state8, '{{$smarty.const.USER_TYPE_CUSTOMER_SERVICE|escape:javascript}}', DlmanageUtils.mixed, 7);

  var transition18 = Transition.instance('received', state2, state3, '{{$smarty.const.USER_TYPE_MANAGER|escape:javascript}}', DlmanageUtils.normal, 5);
  var transition19 = Transition.instance('rmd CUS', state2, state2, '{{$smarty.const.USER_TYPE_MANAGER|escape:javascript}}', DlmanageUtils.mixed, 30);
  var transition20 = Transition.instance('arrange', state3, state4, '{{$smarty.const.USER_TYPE_MANAGER|escape:javascript}}', DlmanageUtils.normal, 0);
  var transition21 = Transition.instance('uploaded', state4, state5, '{{$smarty.const.USER_TYPE_MANAGER|escape:javascript}}', DlmanageUtils.normal, 1);
  var transition22 = Transition.instance('downloaded', state5, state6, '{{$smarty.const.USER_TYPE_MANAGER|escape:javascript}}', DlmanageUtils.normal, 9);
  var transition23 = Transition.instance('uploaded', state6, state7, '{{$smarty.const.USER_TYPE_MANAGER|escape:javascript}}', DlmanageUtils.normal, 3);
  var transition24 = Transition.instance('sent', state7, state8, '{{$smarty.const.USER_TYPE_MANAGER|escape:javascript}}', DlmanageUtils.normal, 14);
  var transition25 = Transition.instance('received', state8, state9, '{{$smarty.const.USER_TYPE_MANAGER|escape:javascript}}', DlmanageUtils.normal, 3);
  var transition26 = Transition.instance('rmd CUS', state8, state8, '{{$smarty.const.USER_TYPE_MANAGER|escape:javascript}}', DlmanageUtils.mixed, 7);
  var transition27 = Transition.instance('confirmed', state9, state12, '{{$smarty.const.USER_TYPE_MANAGER|escape:javascript}}', DlmanageUtils.normal, 1);
  var transition28 = Transition.instance('modify', state9, state10, '{{$smarty.const.USER_TYPE_MANAGER|escape:javascript}}', DlmanageUtils.normal, 0);
  var transition29 = Transition.instance('uploaded', state10, state11, '{{$smarty.const.USER_TYPE_MANAGER|escape:javascript}}', DlmanageUtils.normal, 1);
  var transition30 = Transition.instance('downloaded', state11, state6, '{{$smarty.const.USER_TYPE_MANAGER|escape:javascript}}', DlmanageUtils.normal, 9);
  var transition31 = Transition.instance('uploaded', state12, state13, '{{$smarty.const.USER_TYPE_MANAGER|escape:javascript}}', DlmanageUtils.normal,2);
  var transition32 = Transition.instance('downloaded', state13, state14, '{{$smarty.const.USER_TYPE_MANAGER|escape:javascript}}', DlmanageUtils.none, 2);
  
  var transition33 = Transition.instance('received', state2, state3, '{{$smarty.const.USER_TYPE_ADMIN|escape:javascript}}', DlmanageUtils.normal, 5);
  var transition34 = Transition.instance('rmd CUS', state2, state2, '{{$smarty.const.USER_TYPE_ADMIN|escape:javascript}}', DlmanageUtils.mixed, 30);
  var transition35 = Transition.instance('arrange', state3, state4, '{{$smarty.const.USER_TYPE_ADMIN|escape:javascript}}', DlmanageUtils.normal, 0);
  var transition36 = Transition.instance('uploaded', state4, state5, '{{$smarty.const.USER_TYPE_ADMIN|escape:javascript}}', DlmanageUtils.normal, 1);
  var transition37 = Transition.instance('downloaded', state5, state6, '{{$smarty.const.USER_TYPE_ADMIN|escape:javascript}}', DlmanageUtils.normal, 9);
  var transition38 = Transition.instance('uploaded', state6, state7, '{{$smarty.const.USER_TYPE_ADMIN|escape:javascript}}', DlmanageUtils.normal, 3);
  var transition39 = Transition.instance('sent', state7, state8, '{{$smarty.const.USER_TYPE_ADMIN|escape:javascript}}', DlmanageUtils.normal, 14);
  var transition40 = Transition.instance('received', state8, state9, '{{$smarty.const.USER_TYPE_ADMIN|escape:javascript}}', DlmanageUtils.normal, 3);
  var transition41 = Transition.instance('rmd CUS', state8, state8, '{{$smarty.const.USER_TYPE_ADMIN|escape:javascript}}', DlmanageUtils.mixed, 7);
  var transition42 = Transition.instance('confirmed', state9, state12, '{{$smarty.const.USER_TYPE_ADMIN|escape:javascript}}', DlmanageUtils.normal, 1);
  var transition43 = Transition.instance('modify', state9, state10, '{{$smarty.const.USER_TYPE_ADMIN|escape:javascript}}', DlmanageUtils.normal, 0);
  var transition44 = Transition.instance('uploaded', state10, state11, '{{$smarty.const.USER_TYPE_ADMIN|escape:javascript}}', DlmanageUtils.normal, 1);
  var transition45 = Transition.instance('downloaded', state11, state6, '{{$smarty.const.USER_TYPE_ADMIN|escape:javascript}}', DlmanageUtils.normal, 9);
  var transition46 = Transition.instance('uploaded', state12, state13, '{{$smarty.const.USER_TYPE_ADMIN|escape:javascript}}', DlmanageUtils.normal,2);
  var transition47 = Transition.instance('downloaded', state13, state14, '{{$smarty.const.USER_TYPE_ADMIN|escape:javascript}}', DlmanageUtils.none, 2);
  
  
  transition2.validate = function(produce, user, date, options) { if (transition2.position != user.type) { return false; } if (SimpleDate.toStamp(date) < SimpleDate.toStamp(produce.deadline)) { return false; } else { return true; } };
  transition9.validate = function(produce, user, date, options) { if (transition9.position != user.type) { return false; } if (SimpleDate.toStamp(date) < SimpleDate.toStamp(produce.deadline)) { return false; } else { return true; } };
  
  transition17.validate = function(produce, user, date, options) { if (transition17.position != user.type) { return false; } if (SimpleDate.toStamp(date) < SimpleDate.toStamp(produce.deadline)) { return false; } else { return true; } };
  
  transition19.validate = function(produce, user, date, options) { if (transition19.position != user.type) { return false; } if (SimpleDate.toStamp(date) < SimpleDate.toStamp(produce.deadline)) { return false; } else { return true; } };
  transition26.validate = function(produce, user, date, options) { if (transition26.position != user.type) { return false; } if (SimpleDate.toStamp(date) < SimpleDate.toStamp(produce.deadline)) { return false; } else { return true; } };
  
  transition34.validate = function(produce, user, date, options) { if (transition34.position != user.type) { return false; } if (SimpleDate.toStamp(date) < SimpleDate.toStamp(produce.deadline)) { return false; } else { return true; } };
  transition41.validate = function(produce, user, date, options) { if (transition41.position != user.type) { return false; } if (SimpleDate.toStamp(date) < SimpleDate.toStamp(produce.deadline)) { return false; } else { return true; } };
  
  transition1.operate = function(pos, callbackFunc, produce, user, date, options) { if (!options) {
                                                                                      options = {};
                                                                                    }
                                                                                    var previous = MiscUtils.clone(produce);
                                                                                    options.previous = previous;
                                                                                    var div = document.createElement('div');
                                                                                    var func1 = function() { if (produce._method == '') {
                                                                                                               window.alert('CAN NOT BE EMPTY');
                                                                                                               return;
                                                                                                             }
                                                                                                             if (!options) {
                                                                                                               options = {};
                                                                                                             }
                                                                                                             options.extra = produce._method;
                                                                                                             DlmanageUtils.operate(transition1, pos, callbackFunc, produce, user, date, options);
                                                                                                             popupBox2._close();
                                                                                                           };
                                                                                    var func2 = function() { popupBox2._close();
                                                                                                             callbackFunc();
                                                                                                           };
                                                                                    MiscUtils.dialog(popupBox2, pos, div, func1, func2, { t: 'Method', width: 520, height: 80, func: func2});
                                                                                    new DialogMethod(div, produce, null);
                                                                                  };
  
  transition3.operate = function(pos, callbackFunc, produce, user, date, options) { if (!options) {
                                                                                      options = {};
                                                                                    }
                                                                                    var previous = MiscUtils.clone(produce);
                                                                                    options.previous = previous;
                                                                                    var div = document.createElement('div');
                                                                                    var object = produce;
                                                                                    var func11 = function() { options.branch = object.branch;
                                                                                                              options.host = object.host;
                                                                                                              options.orderDate = object.date;
                                                                                                              options.user = user;
                                                                                                              options.date = date;
                                                                                                              options.orderFlag = object.orderFlag;
                                                                                                              options.orderTrackId = object.orderTrackId;
                                                                                                              options.orderId = object.orderId;
                                                                                                              options.customerId = object.customerId;
                                                                                                              options._modified = true;
                                                                                                              var result = DlmanageUtils.synchronise(object._purchaseItems, [object], options);
                                                                                                              var produce = result.produces[0];
                                                                                                              var ps = result.produceSelects;
                                                                                                              var func1 = function() { if (!options) {
                                                                                                                                           options = {};
                                                                                                                                         }
                                                                                                                                         if (produce.user_account == '') {
                                                                                                                                           window.alert('选择一个设计师');
                                                                                                                                           return;
                                                                                                                                         }
                                                                                                                                         options.extra = produce.user_account;
                                                                                                                                         var delSels = []; mdySels = []; mdyPurs = [];
                                                                                                                                         for (var i = 0, il = produce._purchaseItems.length; i < il; i++) {
                                                                                                                                           var pur = produce._purchaseItems[i];
                                                                                                                                           for (var j = 0, jl = pur.selects.length; j < jl; j++) {
                                                                                                                                             var sel = pur.selects[j];
                                                                                                                                             if (sel._deleted) {
                                                                                                                                               delSels[delSels.length] = sel;
                                                                                                                                             } else {
                                                                                                                                               mdySels[mdySels.length] = sel;
                                                                                                                                             }
                                                                                                                                           }
                                                                                                                                           mdyPurs[mdyPurs.length] = pur;
                                                                                                                                         }
                                                                                                                                         new RequestUtils()._write2([{ n: 'v2purchaseitem', a: mdyPurs, r: []}, { n: 'v2purchaseitemselect', a: mdySels, r: delSels }], function() { var t = DlmanageUtils.getTrack(((options && options.previous) ? options.previous : produce), user, date, transition3, ((options && options.extra) ? ' ' + options.extra : ''));
                                                                                                                                                                                                                                                                                     var e = DlmanageUtils.record(produce, user, date, transition3, ((options && options.extra) ? options.extra : null), ((options && options.overdueReason) ? options.overdueReason : null));
                                                                                                                                                                                                                                                                                     DlmanageUtils.transit(transition3, produce, date);
                                                                                                                                                                                                                                                                                     new RequestUtils()._write2([{ n: 'produce', a: [produce], r: [] }, { n: 'produceevent', a: [e], r: [] }, { n: 'producetrack', a: [t], r: []}, { n: 'produceselect', a: ps, r: []}], callbackFunc, { php: '{{$smarty.const.FACTORY|escape:javascript}}/customphp/mysqlwrite2.php', pos: pos });
                                                                                                                                                                                                                                                                                   }, { pos: pos });
                                                                                                                                         popupBox._close();
                                                                                                                                       };
                                                                                                                var func2 = function() { popupBox._close();
                                                                                                                                         callbackFunc();
                                                                                                                                       };
                                                                                                                var div = document.createElement('div');
                                                                                                                MiscUtils.dialog(popupBox, pos, div, func1, func2);
                                                                                                                new DialogAssignee(div, produce, { php: '{{$smarty.const.FACTORY|escape:javascript}}/customphp/mysqlread.php', condition: 'd.type = \'{{$smarty.const.USER_TYPE_DESIGNER|escape:javascript}}\'' });
                                                                                                                popupBox2._close();
                                                                                                             };
                                                                                    var func22 = function() { popupBox2._close();
                                                                                                              callbackFunc();
                                                                                                            };
                                                                                    MiscUtils.dialog(popupBox2, pos, div, func11, func22, {t: 'Change Album Design', width: 800, height: 100, func: function() { callbackFunc(); } });
                                                                                    new TableModifyDesign(div, object, { user: user, date: date})
                                                                                  };
  
  transition8.operate = function(pos, callbackFunc, produce, user, date, options) { if (!options) {
                                                                                      options = {};
                                                                                    }
                                                                                    var previous = MiscUtils.clone(produce);
                                                                                    options.previous = previous;
                                                                                    var div = document.createElement('div');
                                                                                    var func1 = function() { if (produce._method == '') {
                                                                                                               window.alert('CAN NOT BE EMPTY');
                                                                                                               return;
                                                                                                             }
                                                                                                             if (!options) {
                                                                                                               options = {};
                                                                                                             }
                                                                                                             options.extra = produce._method;
                                                                                                             DlmanageUtils.operate(transition8, pos, callbackFunc, produce, user, date, options);
                                                                                                             popupBox2._close();
                                                                                                           };
                                                                                    var func2 = function() { popupBox2._close();
                                                                                                             callbackFunc();
                                                                                                           };
                                                                                    MiscUtils.dialog(popupBox2, pos, div, func1, func2, { t: 'Method', width: 520, height: 80, func: func2});
                                                                                    new DialogMethod(div, produce, null);
                                                                                  };
  
  transition10.operate = function(pos, callbackFunc, produce, user, date, options) { var tmp = window.confirm('请确认已经“上传小样”和“布置制作任务给工厂”,是否继续？');
                                                                                     if (tmp) {
                                                                                       DlmanageUtils.operate(transition10, pos, callbackFunc, produce, user, date, options);
                                                                                     } else {
                                                                                       callbackFunc();
                                                                                     }
                                                                                   };
  
  transition11.operate = function(pos, callbackFunc, produce, user, date, options) { if (!options) {
                                                                                       options = {};
                                                                                     }
                                                                                     var previous = MiscUtils.clone(produce);
                                                                                     options.previous = previous;
                                                                                     produce.modified = 1;
                                                                                     DlmanageUtils.operate(transition11, pos, callbackFunc, produce, user, date, options);
                                                                                   };
  
  transition15.operate = function(pos, callbackFunc, produce, user, date, options) { if (!options) {
                                                                                       options = {};
                                                                                     }
                                                                                     options.branch = produce.branch;
                                                                                     options.host = produce.host;
                                                                                     options.orderDate = produce.date;
                                                                                     options.user = user;
                                                                                     options.date = date;
                                                                                     options.orderFlag = produce.orderFlag;
                                                                                     options.orderTrackId = produce.orderTrackId;
                                                                                     options.orderId = produce.orderId;
                                                                                     options.customerId = produce.customerId;
                                                                                     DlmanageUtils.operate2(transition15, pos, callbackFunc, produce, user, date, options);
                                                                                   };

  transition16.operate = function(pos, callbackFunc, produce, user, date, options) { if (!options) {
                                                                                      options = {};
                                                                                    }
                                                                                    var previous = MiscUtils.clone(produce);
                                                                                    options.previous = previous;
                                                                                     var div = document.createElement('div');
                                                                                     var func1 = function() { if (produce._method == '') {
                                                                                                                window.alert('CAN NOT BE EMPTY');
                                                                                                                return;
                                                                                                              }
                                                                                                              if (!options) {
                                                                                                                options = {};
                                                                                                              }
                                                                                                              options.extra = produce._method;
                                                                                                              DlmanageUtils.operate(transition16, pos, callbackFunc, produce, user, date, options);
                                                                                                              popupBox2._close();
                                                                                                            };
                                                                                     var func2 = function() { popupBox2._close();
                                                                                                              callbackFunc();
                                                                                                            };
                                                                                     MiscUtils.dialog(popupBox2, pos, div, func1, func2, { t: 'Method', width: 520, height: 80, func: func2});
                                                                                     new DialogMethod(div, produce, null);
                                                                                   };
                                                                                   
  transition18.operate = function(pos, callbackFunc, produce, user, date, options) { if (!options) {
                                                                                       options = {};
                                                                                     }
                                                                                     var previous = MiscUtils.clone(produce);
                                                                                     options.previous = previous;
                                                                                     var div = document.createElement('div');
                                                                                     var func1 = function() { if (produce._method == '') {
                                                                                                                window.alert('CAN NOT BE EMPTY');
                                                                                                                return;
                                                                                                              }
                                                                                                              if (!options) {
                                                                                                                options = {};
                                                                                                              }
                                                                                                              options.extra = produce._method;
                                                                                                              DlmanageUtils.operate(transition18, pos, callbackFunc, produce, user, date, options);
                                                                                                              popupBox2._close();
                                                                                                            };
                                                                                     var func2 = function() { popupBox2._close();
                                                                                                              callbackFunc();
                                                                                                            };
                                                                                     MiscUtils.dialog(popupBox2, pos, div, func1, func2, { t: 'Method', width: 520, height: 80, func: func2});
                                                                                     new DialogMethod(div, produce, null);
                                                                                   };
 
  transition20.operate = function(pos, callbackFunc, produce, user, date, options) { if (!options) {
                                                                                       options = {};
                                                                                     }
                                                                                     var previous = MiscUtils.clone(produce);
                                                                                     options.previous = previous;
                                                                                     var div = document.createElement('div');
                                                                                     var object = produce;
                                                                                     var func11 = function() { options.branch = object.branch;
                                                                                                               options.host = object.host;
                                                                                                               options.orderDate = object.date;
                                                                                                               options.user = user;
                                                                                                               options.date = date;
                                                                                                               options.orderFlag = object.orderFlag;
                                                                                                               options.orderTrackId = object.orderTrackId;
                                                                                                               options.orderId = object.orderId;
                                                                                                               options.customerId = object.customerId;
                                                                                                               options._modified = true;
                                                                                                               var result = DlmanageUtils.synchronise(object._purchaseItems, [object], options);
                                                                                                               var produce = result.produces[0];
                                                                                                               var ps = result.produceSelects;
                                                                                                               var func1 = function() { if (!options) {
                                                                                                                                            options = {};
                                                                                                                                          }
                                                                                                                                          if (produce.user_account == '') {
                                                                                                                                            window.alert('选择一个设计师');
                                                                                                                                            return;
                                                                                                                                          }
                                                                                                                                          options.extra = produce.user_account;
                                                                                                                                          var delSels = []; mdySels = []; mdyPurs = [];
                                                                                                                                          for (var i = 0, il = produce._purchaseItems.length; i < il; i++) {
                                                                                                                                            var pur = produce._purchaseItems[i];
                                                                                                                                            for (var j = 0, jl = pur.selects.length; j < jl; j++) {
                                                                                                                                              var sel = pur.selects[j];
                                                                                                                                              if (sel._deleted) {
                                                                                                                                                delSels[delSels.length] = sel;
                                                                                                                                              } else {
                                                                                                                                                mdySels[mdySels.length] = sel;
                                                                                                                                              }
                                                                                                                                            }
                                                                                                                                            mdyPurs[mdyPurs.length] = pur;
                                                                                                                                          }
                                                                                                                                          new RequestUtils()._write2([{ n: 'v2purchaseitem', a: mdyPurs, r: []}, { n: 'v2purchaseitemselect', a: mdySels, r: delSels }], function() { var t = DlmanageUtils.getTrack(((options && options.previous) ? options.previous : produce), user, date, transition3, ((options && options.extra) ? ' ' + options.extra : ''));
                                                                                                                                                                                                                                                                                      var e = DlmanageUtils.record(produce, user, date, transition3, ((options && options.extra) ? options.extra : null), ((options && options.overdueReason) ? options.overdueReason : null));
                                                                                                                                                                                                                                                                                      DlmanageUtils.transit(transition20, produce, date);
                                                                                                                                                                                                                                                                                      new RequestUtils()._write2([{ n: 'produce', a: [produce], r: [] }, { n: 'produceevent', a: [e], r: [] }, { n: 'producetrack', a: [t], r: []}, { n: 'produceselect', a: ps, r: []}], callbackFunc, { php: '{{$smarty.const.FACTORY|escape:javascript}}/customphp/mysqlwrite2.php', pos: pos });
                                                                                                                                                                                                                                                                                    }, { pos: pos });
                                                                                                                                          popupBox._close();
                                                                                                                                        };
                                                                                                                 var func2 = function() { popupBox._close();
                                                                                                                                          callbackFunc();
                                                                                                                                        };
                                                                                                                 var div = document.createElement('div');
                                                                                                                 MiscUtils.dialog(popupBox, pos, div, func1, func2);
                                                                                                                 new DialogAssignee(div, produce, { php: '{{$smarty.const.FACTORY|escape:javascript}}/customphp/mysqlread.php', condition: 'd.type = \'{{$smarty.const.USER_TYPE_DESIGNER|escape:javascript}}\'' });
                                                                                                                 popupBox2._close();
                                                                                                              };
                                                                                     var func22 = function() { popupBox2._close();
                                                                                                               callbackFunc();
                                                                                                             };
                                                                                     MiscUtils.dialog(popupBox2, pos, div, func11, func22, {t: 'Change Album Design', width: 800, height: 100, func: function() { callbackFunc(); } });
                                                                                     new TableModifyDesign(div, object, { user: user, date: date})
                                                                                   };
 
  transition25.operate = function(pos, callbackFunc, produce, user, date, options) { if (!options) {
                                                                                       options = {};
                                                                                     }
                                                                                     var previous = MiscUtils.clone(produce);
                                                                                     options.previous = previous;
                                                                                     var div = document.createElement('div');
                                                                                     var func1 = function() { if (produce._method == '') {
                                                                                                                window.alert('CAN NOT BE EMPTY');
                                                                                                                return;
                                                                                                              }
                                                                                                              if (!options) {
                                                                                                                options = {};
                                                                                                              }
                                                                                                              options.extra = produce._method;
                                                                                                              DlmanageUtils.operate(transition25, pos, callbackFunc, produce, user, date, options);
                                                                                                              popupBox2._close();
                                                                                                            };
                                                                                     var func2 = function() { popupBox2._close();
                                                                                                              callbackFunc();
                                                                                                            };
                                                                                     MiscUtils.dialog(popupBox2, pos, div, func1, func2, { t: 'Method', width: 520, height: 80, func: func2});
                                                                                     new DialogMethod(div, produce, null);
                                                                                   };
 
  transition27.operate = function(pos, callbackFunc, produce, user, date, options) { var tmp = window.confirm('请确认已经“上传小样”和“布置制作任务给工厂”,是否继续？');
                                                                                     if (tmp) {
                                                                                       DlmanageUtils.operate(transition27, pos, callbackFunc, produce, user, date, options);
                                                                                     } else {
                                                                                       callbackFunc();
                                                                                     }
                                                                                   };
 
  transition28.operate = function(pos, callbackFunc, produce, user, date, options) { if (!options) {
                                                                                      options = {};
                                                                                    }
                                                                                    var previous = MiscUtils.clone(produce);
                                                                                    options.previous = previous;
                                                                                    produce.modified = 1;
                                                                                    DlmanageUtils.operate(transition28, pos, callbackFunc, produce, user, date, options);
                                                                                  };
 
  transition32.operate = function(pos, callbackFunc, produce, user, date, options) { if (!options) {
                                                                                      options = {};
                                                                                    }
                                                                                    options.branch = produce.branch;
                                                                                    options.host = produce.host;
                                                                                    options.orderDate = produce.date;
                                                                                    options.user = user;
                                                                                    options.date = date;
                                                                                    options.orderFlag = produce.orderFlag;
                                                                                    options.orderTrackId = produce.orderTrackId;
                                                                                    options.orderId = produce.orderId;
                                                                                    options.customerId = produce.customerId;
                                                                                    DlmanageUtils.operate2(transition32, pos, callbackFunc, produce, user, date, options);
                                                                                  };
                                                                                  
transition33.operate = function(pos, callbackFunc, produce, user, date, options) { if (!options) {
                                                                                    options = {};
                                                                                  }
                                                                                  var previous = MiscUtils.clone(produce);
                                                                                  options.previous = previous;
                                                                                  var div = document.createElement('div');
                                                                                  var func1 = function() { if (produce._method == '') {
                                                                                                             window.alert('CAN NOT BE EMPTY');
                                                                                                             return;
                                                                                                           }
                                                                                                           if (!options) {
                                                                                                             options = {};
                                                                                                           }
                                                                                                           options.extra = produce._method;
                                                                                                           DlmanageUtils.operate(transition33, pos, callbackFunc, produce, user, date, options);
                                                                                                           popupBox2._close();
                                                                                                         };
                                                                                  var func2 = function() { popupBox2._close();
                                                                                                           callbackFunc();
                                                                                                         };
                                                                                  MiscUtils.dialog(popupBox2, pos, div, func1, func2, { t: 'Method', width: 520, height: 80, func: func2});
                                                                                  new DialogMethod(div, produce, null);
                                                                                };

transition35.operate = function(pos, callbackFunc, produce, user, date, options) { if (!options) {
                                                                                    options = {};
                                                                                  }
                                                                                  var previous = MiscUtils.clone(produce);
                                                                                  options.previous = previous;
                                                                                  var div = document.createElement('div');
                                                                                  var object = produce;
                                                                                  var func11 = function() { options.branch = object.branch;
                                                                                                            options.host = object.host;
                                                                                                            options.orderDate = object.date;
                                                                                                            options.user = user;
                                                                                                            options.date = date;
                                                                                                            options.orderFlag = object.orderFlag;
                                                                                                            options.orderTrackId = object.orderTrackId;
                                                                                                            options.orderId = object.orderId;
                                                                                                            options.customerId = object.customerId;
                                                                                                            options._modified = true;
                                                                                                            var result = DlmanageUtils.synchronise(object._purchaseItems, [object], options);
                                                                                                            var produce = result.produces[0];
                                                                                                            var ps = result.produceSelects;
                                                                                                            var func1 = function() { if (!options) {
                                                                                                                                         options = {};
                                                                                                                                       }
                                                                                                                                       if (produce.user_account == '') {
                                                                                                                                         window.alert('选择一个设计师');
                                                                                                                                         return;
                                                                                                                                       }
                                                                                                                                       options.extra = produce.user_account;
                                                                                                                                       var delSels = []; mdySels = []; mdyPurs = [];
                                                                                                                                       for (var i = 0, il = produce._purchaseItems.length; i < il; i++) {
                                                                                                                                         var pur = produce._purchaseItems[i];
                                                                                                                                         for (var j = 0, jl = pur.selects.length; j < jl; j++) {
                                                                                                                                           var sel = pur.selects[j];
                                                                                                                                           if (sel._deleted) {
                                                                                                                                             delSels[delSels.length] = sel;
                                                                                                                                           } else {
                                                                                                                                             mdySels[mdySels.length] = sel;
                                                                                                                                           }
                                                                                                                                         }
                                                                                                                                         mdyPurs[mdyPurs.length] = pur;
                                                                                                                                       }
                                                                                                                                       new RequestUtils()._write2([{ n: 'v2purchaseitem', a: mdyPurs, r: []}, { n: 'v2purchaseitemselect', a: mdySels, r: delSels }], function() { var t = DlmanageUtils.getTrack(((options && options.previous) ? options.previous : produce), user, date, transition3, ((options && options.extra) ? ' ' + options.extra : ''));
                                                                                                                                                                                                                                                                                   var e = DlmanageUtils.record(produce, user, date, transition3, ((options && options.extra) ? options.extra : null), ((options && options.overdueReason) ? options.overdueReason : null));
                                                                                                                                                                                                                                                                                   DlmanageUtils.transit(transition35, produce, date);
                                                                                                                                                                                                                                                                                   new RequestUtils()._write2([{ n: 'produce', a: [produce], r: [] }, { n: 'produceevent', a: [e], r: [] }, { n: 'producetrack', a: [t], r: []}, { n: 'produceselect', a: ps, r: []}], callbackFunc, { php: '{{$smarty.const.FACTORY|escape:javascript}}/customphp/mysqlwrite2.php', pos: pos });
                                                                                                                                                                                                                                                                                 }, { pos: pos });
                                                                                                                                       popupBox._close();
                                                                                                                                     };
                                                                                                              var func2 = function() { popupBox._close();
                                                                                                                                       callbackFunc();
                                                                                                                                     };
                                                                                                              var div = document.createElement('div');
                                                                                                              MiscUtils.dialog(popupBox, pos, div, func1, func2);
                                                                                                              new DialogAssignee(div, produce, { php: '{{$smarty.const.FACTORY|escape:javascript}}/customphp/mysqlread.php', condition: 'd.type = \'{{$smarty.const.USER_TYPE_DESIGNER|escape:javascript}}\'' });
                                                                                                              popupBox2._close();
                                                                                                           };
                                                                                  var func22 = function() { popupBox2._close();
                                                                                                            callbackFunc();
                                                                                                          };
                                                                                  MiscUtils.dialog(popupBox2, pos, div, func11, func22, {t: 'Change Album Design', width: 800, height: 100, func: function() { callbackFunc(); } });
                                                                                  new TableModifyDesign(div, object, { user: user, date: date})
                                                                                };

transition40.operate = function(pos, callbackFunc, produce, user, date, options) { if (!options) {
                                                                                    options = {};
                                                                                  }
                                                                                  var previous = MiscUtils.clone(produce);
                                                                                  options.previous = previous;
                                                                                  var div = document.createElement('div');
                                                                                  var func1 = function() { if (produce._method == '') {
                                                                                                             window.alert('CAN NOT BE EMPTY');
                                                                                                             return;
                                                                                                           }
                                                                                                           if (!options) {
                                                                                                             options = {};
                                                                                                           }
                                                                                                           options.extra = produce._method;
                                                                                                           DlmanageUtils.operate(transition40, pos, callbackFunc, produce, user, date, options);
                                                                                                           popupBox2._close();
                                                                                                         };
                                                                                  var func2 = function() { popupBox2._close();
                                                                                                           callbackFunc();
                                                                                                         };
                                                                                  MiscUtils.dialog(popupBox2, pos, div, func1, func2, { t: 'Method', width: 520, height: 80, func: func2});
                                                                                  new DialogMethod(div, produce, null);
                                                                                };

transition42.operate = function(pos, callbackFunc, produce, user, date, options) { var tmp = window.confirm('请确认已经“上传小样”和“布置制作任务给工厂”,是否继续？');
                                                                                  if (tmp) {
                                                                                    DlmanageUtils.operate(transition42, pos, callbackFunc, produce, user, date, options);
                                                                                  } else {
                                                                                    callbackFunc();
                                                                                  }
                                                                                };

transition43.operate = function(pos, callbackFunc, produce, user, date, options) { if (!options) {
                                                                                   options = {};
                                                                                 }
                                                                                 var previous = MiscUtils.clone(produce);
                                                                                 options.previous = previous;
                                                                                 produce.modified = 1;
                                                                                 DlmanageUtils.operate(transition43, pos, callbackFunc, produce, user, date, options);
                                                                               };

transition47.operate = function(pos, callbackFunc, produce, user, date, options) { if (!options) {
                                                                                   options = {};
                                                                                 }
                                                                                 options.branch = produce.branch;
                                                                                 options.host = produce.host;
                                                                                 options.orderDate = produce.date;
                                                                                 options.user = user;
                                                                                 options.date = date;
                                                                                 options.orderFlag = produce.orderFlag;
                                                                                 options.orderTrackId = produce.orderTrackId;
                                                                                 options.orderId = produce.orderId;
                                                                                 options.customerId = produce.customerId;
                                                                                 DlmanageUtils.operate2(transition47, pos, callbackFunc, produce, user, date, options);
                                                                               };
                                                                                  
                                                                                  
  model.states = [ state1, state2, state3, state4, state5, state6, state7, state8, state9, state10, state11, state12, state13, state14 ];
  model.transitions = [ transition1, transition2, transition3, transition4, transition5, transition6, transition7, transition8, transition9, transition10, transition11, transition12, transition13, transition14, transition15, transition16, transition17, transition18, transition19, transition20, 
                        transition21, transition22, transition23, transition24, transition25, transition26, transition27, transition28, transition29, transition30, transition31, transition32, transition33, transition34, transition35, transition36, transition37, transition38, transition39, transition40,
                        transition41, transition42, transition43, transition44, transition45, transition46, transition47];
  return model;
};